package com.wyl.wyl.testapplication.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.inossem.utils.log.LogUtils;
import com.wyl.wyl.testapplication.MyApplication;

/**
 * @author 王斯宇
 * @time on 2019/5/22 16:04
 * @email siyu.wang@inossem.com
 */
public class BaseActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        try {
            super.onCreate(savedInstanceState);
//            requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置无标题
//            //设置全屏
//            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            MyApplication.getInstance().pushActivity(this);
            LogUtils.i("当前页面ClassName【" + this.getComponentName().getClassName() + "】");
//            AppCompatActivity下设置无标题
//            getSupportActionBar().hide();
            onCreateImpl(savedInstanceState);
        } catch (Throwable throwable) {
            LogUtils.logThrowableE(this, "", throwable);
        }
    }

    @Override
    protected void onStart() {
        try {
            super.onStart();
            onStartImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    @Override
    protected void onRestart() {
        try {
            super.onRestart();
            onRestartImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    @Override
    protected void onResume() {
        try {
            super.onResume();
            onResumeImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    @Override
    protected void onPause() {
        try {
            super.onPause();
            onPauseImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    @Override
    protected void onStop() {
        try {
            super.onStop();
            onStopImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }

    }

    @Override
    protected void onDestroy() {
        try {
            super.onDestroy();
            MyApplication.getInstance().popActivity(this);
            onDestroyImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    }

    @Override
    protected void onUserLeaveHint() {
        try {
            super.onUserLeaveHint();
            onUserLeaveHintImpl();
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        try {
            super.onWindowFocusChanged(hasFocus);
            onWindowFocusChangedImpl(hasFocus);
        } catch (Throwable Throwable) {
            LogUtils.logThrowableE(this, "", Throwable);
        }
    }

    protected void onCreateImpl(Bundle savedInstanceState) {
    }

    protected void onStartImpl() {
    }

    protected void onRestartImpl() {
    }

    protected void onResumeImpl() {
    }

    protected void onPauseImpl() {
    }

    protected void onStopImpl() {
    }

    protected void onDestroyImpl() {
    }

    protected void onActivityResultImpl(int requestCode, int resultCode, Intent data) {

    }

    protected void onUserLeaveHintImpl() {
    }

    public void onWindowFocusChangedImpl(boolean hasFocus) {
    }


}
